/*
 * @Description:
 * @Author: Tsingwong
 * @Date: 2020-11-27 11:02:59
 * @LastEditors: Tsingwong
 * @LastEditTime: 2020-12-01 19:28:29
 */
import Axios from 'axios'
import { SET_DETAIL_DATA } from './actionType'

export const getDetailData = (params) => {
  return (dispatch, getState) => {
    Axios.get('/api/detail.json', {
      params,
    })
      .then((res) => {
        if (res?.data?.success) {
          const { title, content } = res.data.data
          dispatch(setDetailData(title, content))
        }
      })
      .catch(() => {
        //
      })
  }
}

const setDetailData = (title, content) => ({
  type: SET_DETAIL_DATA,
  title,
  content,
})
